﻿using System;
using System.Data;
using System.Web;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
namespace AnyOffice.general.system.workflow.flow_type
{
    public partial class select_user : ModulePage
    {
        public string strUserList = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            int ol = (Request.QueryString["id"] == null) ? 0 : int.Parse(Request.QueryString["id"].ToString());
            this.ViewState["Id"] = ol;
            FlowProcessDao dao = new FlowProcessDao();
            DataView defaultView = dao.ByUser(base.Conn, ol).DefaultView;
            if ((Request.QueryString["dept_id"] == null) && (Request.QueryString["priv_id"] == null))
            {
                this.litTitle.Text = "全部经办人";
                if (defaultView.Count > 0)
                {
                    for (int i = 0; i < defaultView.Count; i++)
                    {
                        string strUserList = this.strUserList;
                        this.strUserList = strUserList + "userlist[" + i.ToString() + "]=\"" + defaultView[i]["UserId"].ToString() + "\";\n";
                    }
                    this.rptUser.DataSource = defaultView;
                    this.rptUser.DataBind();
                }
                else
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = "<tr class=\"TableControl\" align=\"center\"><td >未定义用户</td></tr>";
                }
            }
            if (Request.QueryString["dept_id"] != null)
            {
                int num3 = int.Parse(Request.QueryString["dept_id"].ToString());
                DataTable table2 = new DepartmentDao().SelectByDeptId(base.Conn, num3);
                if (table2.Rows.Count > 0)
                {
                    this.litTitle.Text = table2.Rows[0]["DeptName"].ToString();
                }
                defaultView.RowFilter = "DeptId = " + num3.ToString();
                if (defaultView.Count > 0)
                {
                    for (int j = 0; j < defaultView.Count; j++)
                    {
                        string str2 = this.strUserList;
                        this.strUserList = str2 + "userlist[" + j.ToString() + "]=\"" + defaultView[j]["UserId"].ToString() + "\";\n";
                    }
                    this.rptUser.DataSource = defaultView;
                    this.rptUser.DataBind();
                }
                else
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = "<tr class=\"TableControl\" align=\"center\"><td >未定义用户</td></tr>";
                }
            }
            if (Request.QueryString["priv_id"] != null)
            {
                int num5 = int.Parse(Request.QueryString["priv_id"].ToString());
                DataTable table3 = new UserPrivDao().SelectByPrivId(base.Conn, num5);
                if (table3.Rows.Count > 0)
                {
                    this.litTitle.Text = table3.Rows[0]["PrivName"].ToString();
                }
                defaultView.RowFilter = "PrivId = " + num5.ToString();
                if (defaultView.Count > 0)
                {
                    for (int k = 0; k < defaultView.Count; k++)
                    {
                        string str3 = this.strUserList;
                        this.strUserList = str3 + "userlist[" + k.ToString() + "]=\"" + defaultView[k]["UserId"].ToString() + "\";\n";
                    }
                    this.rptUser.DataSource = defaultView;
                    this.rptUser.DataBind();
                }
                else
                {
                    this.pnlMain.Visible = false;
                    this.litMessage.Text = "<tr class=\"TableControl\" align=\"center\"><td >未定义用户</td></tr>";
                }
            }

        }
    }
}
